package com.eddie.flyweight;

/**
 * @author Eddie
 * @date 2022/08/02 12:08
 **/
public class Client {
    public static void main(String[] args) {

        //创建一个工厂类
        WebSiteFactory webSiteFactory = new WebSiteFactory();
        //客户要以一个新闻形式发布的网站
        WebSite webSite1 = webSiteFactory.getWebSiteCategory("新闻");
        WebSite webSite2 = webSiteFactory.getWebSiteCategory("博客");
        WebSite webSite3 = webSiteFactory.getWebSiteCategory("博客");
        WebSite webSite4 = webSiteFactory.getWebSiteCategory("新闻");

        webSite1.use(new User("Eddie"));
        webSite2.use(new User("REACT"));
        webSite3.use(new User("YA-SSO"));
        webSite4.use(new User("TOM"));
        System.out.println(webSiteFactory.getWebSiteCount());

    }


    public void test() {
        Integer x = Integer.valueOf(127);
        Integer t = Integer.valueOf(127);
        System.out.println(x==t);//true
        //因为在Integer底层中，-128 ~ 127之间包含的数比较常用，所以就在这个区间使用了享元模式，在这个区间就直接从缓存池返回

    }
}
